package com.creatified.jacqueline;

import java.io.File;
import java.io.FilenameFilter;


/**
 * A simple implementation of FilenameFilter which will check the filename against a regex pattern.
 */
public final class RegexFilenameFilter implements FilenameFilter {
	
	private String filterExpr;
	
	/**
	 * Instantiates a new RegexFilenameFilter
	 * 
	 * @param filterExpr the regular filter expression
	 */
	protected RegexFilenameFilter(String filterExpr) {
		this.filterExpr = filterExpr;
	}
	
	/* (non-Javadoc)
	 * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
	 */
	public boolean accept(File dir, String name) {
		return name.matches(this.filterExpr);
	}
}
